﻿using System;
using Classes;

namespace Indexers
{
    class Program
    {
        static void Main(string[] args)
        {
            var array = new int[2];
            array[0] = 1;
            var a1 = array[1];

            var greeting = "Hello World!";
            char ch;
            for (int i = 0; i < greeting.Length; i++)
            {
                ch = greeting[i];
                Console.Write(ch);
            }

            var proc = new Processor(2, "Intel");
            proc.Cores[0] = new Core("0", 2.5f);
            proc[1] = new Core("0", 2.5f);

            Console.WriteLine();

            var matrix = new Matrix2x2();
            matrix[1, 1] = GetDouble("[1, 1]");
            matrix[1, 2] = GetDouble("[1, 2]");
            matrix[2, 1] = GetDouble("[2, 1]");
            matrix[2, 2] = GetDouble("[2, 2]");

            Console.WriteLine(matrix);

            Console.ReadKey();
        }

        private static double GetDouble(string message = "")
        {
            double result;
            bool isSuccess = default(bool);

            do
            {
                Console.Write("{0} = ", message);
                isSuccess = double.TryParse(Console.ReadLine(), out result);
                if (!isSuccess)
                {
                    Console.WriteLine("Please try again");
                }
            }
            while (!isSuccess);

            return result;
        }
    }
}
